home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 14 / CU Amiga Magazine's Super CD-ROM 14 (1997)(EMAP Images)(GB)(Track 1 of 3)[!][issue 1997-09].iso / CUCD / Programming / IEditor / Generators / C / gadgets.c < prev    next >
Encoding:
C/C++ Source or Header  |  1997-06-17  |  22.7 KB  |  711 lines

  1. /// Includes
  2. #define INTUI_V36_NAMES_ONLY
  3.  
  4. #include <exec/types.h>                 // exec
  5. #include <exec/lists.h>
  6. #include <exec/nodes.h>
  7. #include <dos/dos.h>                    // dos
  8. #include <dos/dostags.h>
  9. #include <intuition/intuition.h>        // intuition
  10. #include <intuition/gadgetclass.h>
  11. #include <libraries/gadtools.h>         // libraries
  12. #include <clib/exec_protos.h>           // protos
  13. #include <clib/dos_protos.h>
  14. #include <clib/intuition_protos.h>
  15. #include <pragmas/exec_pragmas.h>       // pragmas
  16. #include <pragmas/dos_pragmas.h>
  17. #include <pragmas/intuition_pragmas.h>
  18. #include <pragmas/gadtools_pragmas.h>
  19.  
  20. #include <string.h>
  21. #include <stdio.h>
  22. #include <stdlib.h>
  23. #include <ctype.h>
  24.  
  25. #include "DEV_IE:Generators/defs.h"
  26. #include "DEV_IE:Include/IEditor.h"
  27. #include "DEV_IE:Generators/C/Protos.h"
  28. ///
  29. /// Prototypes
  30. static void WriteGED( struct GenFiles *, struct IE_Data *, struct MinList * );
  31. ///
  32. /// Data
  33. static UWORD stringjusts[] = {
  34.     GACT_STRINGLEFT, GACT_STRINGRIGHT, GACT_STRINGCENTER
  35. };
  36.  
  37. static ULONG gadget_flags[] = { 1, 2, 4, 8, 16, 0 };
  38.  
  39. static UBYTE *GadKinds[] = {
  40.     "BUTTON_KIND",
  41.     "CHECKBOX_KIND",
  42.     "INTEGER_KIND",
  43.     "LISTVIEW_KIND",
  44.     "MX_KIND",
  45.     "NUMBER_KIND",
  46.     "CYCLE_KIND",
  47.     "PALETTE_KIND",
  48.     "SCROLLER_KIND",
  49.     NULL,
  50.     "SLIDER_KIND",
  51.     "STRING_KIND",
  52.     "TEXT_KIND"
  53. };
  54.  
  55. static UBYTE  *GadFlags[] = {
  56.     "PLACETEXT_LEFT",
  57.     "PLACETEXT_RIGHT",
  58.     "PLACETEXT_ABOVE",
  59.     "PLACETEXT_BELOW",
  60.     "PLACETEXT_IN"
  61. };
  62.  
  63. static UBYTE  *STRINGA_txts[] = {
  64.     NULL,
  65.     "GACT_STRINGRIGHT",
  66.     "GACT_STRINGCENTER"
  67. };
  68.  
  69. static UBYTE  *GTJ_txts[] = {
  70.     NULL,
  71.     "GTJ_RIGHT",
  72.     "GTJ_CENTER"
  73. };
  74.  
  75. static UBYTE   GADisabled[]         = "(GA_Disabled), TRUE, ";
  76. static UBYTE   GAImmediate[]        = "(GA_Immediate), TRUE, ";
  77. static UBYTE   GATabCycle[]         = "(GA_TabCycle), FALSE, ";
  78. static UBYTE   GARelVerify[]        = "(GA_RelVerify), TRUE, ";
  79. static UBYTE   STRINGAExitHelp[]    = "(STRINGA_ExitHelp), TRUE, ";
  80. static UBYTE   STRINGAReplaceMode[] = "(STRINGA_ReplaceMode), TRUE, ";
  81. static UBYTE   PGAFreedom[]         = "(PGA_Freedom), LORIENT_VERT, ";
  82. static UBYTE   LAYOUTASpacing[]     = "(LAYOUTA_Spacing), %ld, ";
  83. ///
  84.  
  85.  
  86. /// CheckMultiSelect
  87. BOOL CheckMultiSelect( struct IE_Data *IE )
  88. {
  89.     struct WindowInfo  *wnd;
  90.  
  91.     for( wnd = IE->win_list.mlh_Head; wnd->wi_succ; wnd = wnd->wi_succ ) {
  92.     struct GadgetBank  *bank;
  93.  
  94.     if( wnd->wi_NumGads - wnd->wi_NumBools ) {
  95.         struct GadgetInfo  *gad;
  96.  
  97.         for( gad = wnd->wi_Gadgets.mlh_Head; gad->g_Node.ln_Succ; gad = gad->g_Node.ln_Succ )
  98.         if( gad->g_Kind == LISTVIEW_KIND )
  99.             if( ((struct LK)( gad->g_Data )).MultiSelect )
  100.             return( TRUE );
  101.     }
  102.  
  103.     for( bank = wnd->wi_GBanks.mlh_Head; bank->Node.ln_Succ; bank = bank->Node.ln_Succ ) {
  104.         struct GadgetInfo  *gad;
  105.  
  106.         for( gad = bank->Storage.mlh_Head; gad->g_Node.ln_Succ; gad = gad->g_Node.ln_Succ )
  107.         if( gad->g_Kind == LISTVIEW_KIND )
  108.             if( ((struct LK)( gad->g_Data )).MultiSelect )
  109.             return( TRUE );
  110.     }
  111.     }
  112.  
  113.     return( FALSE );
  114. }
  115. ///
  116.  
  117. /// WriteGadgetExtData
  118. void WriteGadgetExtData( struct GenFiles *Files, struct IE_Data *IE )
  119. {
  120.     if( CheckMultiSelect( IE ))
  121.     FPuts( Files->Std, "\nstruct Hook ListHook = {\n"
  122.                "\t{ 0 },\n"
  123.                "\t(HOOKFUNC)ListHookFunc,\n"
  124.                "\tNULL,\n"
  125.                "\tNULL\n"
  126.                "};\n" );
  127. }
  128. ///
  129. /// WriteNewGadgets
  130. void WriteNewGadgets( struct GenFiles *Files, struct IE_Data *IE )
  131. {
  132.     struct WindowInfo  *wnd;
  133.     LONG                loc;
  134.  
  135.     for( wnd = IE->win_list.mlh_Head; wnd->wi_succ; wnd = wnd->wi_succ ) {
  136.     if( wnd->wi_NumGads - wnd->wi_NumBools ) {
  137.  
  138.         FPrintf( Files->XDef, "extern struct NewGadget\t\t%sNGad[];\n", wnd->wi_Label );
  139.         FPrintf( Files->Std, "\nstruct NewGadget %sNGad[] = {\n\t", wnd->wi_Label );
  140.  
  141.         loc = Prefs.Flags & SMART_STR;
  142.  
  143.         if( IE->SrcFlags & LOCALIZE )
  144.         loc = wnd->wi_Tags & W_LOC_GADGETS;
  145.  
  146.         WriteNewGads( Files, IE, &wnd->wi_Gadgets, loc );
  147.     }
  148.     }
  149.  
  150. }
  151. ///
  152. /// WriteGadgetTags
  153. void WriteGadgetTags( struct GenFiles *Files, struct IE_Data *IE )
  154. {
  155.     struct WindowInfo  *wnd;
  156.     ULONG               loc;
  157.  
  158.     for( wnd = IE->win_list.mlh_Head; wnd->wi_succ; wnd = wnd->wi_succ ) {
  159.     if( wnd->wi_NumGads - wnd->wi_NumBools ) {
  160.  
  161.         loc = Prefs.Flags & SMART_STR;
  162.  
  163.         if( IE->SrcFlags & LOCALIZE )
  164.         loc = wnd->wi_Tags & W_LOC_GADGETS;
  165.  
  166.         FPrintf( Files->XDef, "extern ULONG\t\t\t%sGTags[];\n", wnd->wi_Label );
  167.         FPrintf( Files->Std, "\nULONG %sGTags[] = {\n\t", wnd->wi_Label );
  168.  
  169.         WriteTags( Files, IE, &wnd->wi_Gadgets, loc );
  170.     }
  171.     }
  172. }
  173. ///
  174. /// WriteBoolStruct
  175. void WriteBoolStruct( struct GenFiles *Files, struct IE_Data *IE )
  176. {
  177.     struct WindowInfo  *wnd;
  178.  
  179.     for( wnd = IE->win_list.mlh_Head; wnd->wi_succ; wnd = wnd->wi_succ )
  180.     if( wnd->wi_NumBools )
  181.         WriteBooleans( Files, IE, &wnd->wi_Gadgets, wnd );
  182. }
  183. ///
  184. /// WriteGadgetBanks
  185. void WriteGadgetBanks( struct GenFiles *Files, struct IE_Data *IE )
  186. {
  187.     struct WindowInfo  *wnd;
  188.  
  189.     for( wnd = IE->win_list.mlh_Head; wnd->wi_succ; wnd = wnd->wi_succ ) {
  190.     struct GadgetBank  *bank;
  191.     ULONG               loc;
  192.  
  193.     loc = Prefs.Flags & SMART_STR;
  194.  
  195.     if( IE->SrcFlags & LOCALIZE )
  196.         loc = wnd->wi_Tags & W_LOC_GADGETS;
  197.  
  198.     for( bank = wnd->wi_GBanks.mlh_Head; bank->Node.ln_Succ; bank = bank->Node.ln_Succ ) {
  199.         ULONG               NotBool = 0;
  200.         struct GadgetInfo  *gad;
  201.  
  202.         for( gad = bank->Storage.mlh_Head; gad->g_Node.ln_Succ; gad = gad->g_Node.ln_Succ )
  203.         if( gad->g_Kind != BOOLEAN )
  204.             NotBool += 1;
  205.  
  206.         if( NotBool ) {
  207.         FPrintf( Files->XDef, "extern UWORD\t\t\t%sGTypes[];\n", bank->Label );
  208.         FPrintf( Files->Std, "\nUWORD %sGTypes[] = {\n\t", bank->Label );
  209.  
  210.         WriteGTypes( Files, IE, &bank->Storage );
  211.  
  212.         WriteGLabels( Files, IE, &bank->Storage, wnd );
  213.  
  214.         FPrintf( Files->XDef, "extern struct NewGadget\t\t%sNGad[];\n", bank->Label );
  215.         FPrintf( Files->Std, "\nstruct NewGadget %sNGad[] = {\n\t", bank->Label );
  216.  
  217.         WriteNewGads( Files, IE, &bank->Storage, loc );
  218.  
  219.         FPrintf( Files->XDef, "extern ULONG\t\t\t%sGTags[];\n", bank->Label );
  220.         FPrintf( Files->Std, "\nULONG %sGTags[] = {\n\t", bank->Label );
  221.  
  222.         WriteTags( Files, IE, &bank->Storage, loc );
  223.         }
  224.  
  225.         WriteBooleans( Files, IE, &bank->Storage, wnd );
  226.     }
  227.     }
  228. }
  229. ///
  230.  
  231. /// WriteNewGads
  232. void WriteNewGads( struct GenFiles *Files, struct IE_Data *IE, struct MinList *Gadgets, ULONG loc )
  233. {
  234.     struct GadgetInfo  *gad;
  235.     UBYTE               buffer[256], *or;
  236.     UWORD               c, c2;
  237.  
  238.     for( gad = Gadgets->mlh_Head; gad->g_Node.ln_Succ; gad = gad->g_Node.ln_Succ ) {
  239.     if( gad->g_Kind < BOOLEAN ) {
  240.  
  241.         FPrintf( Files->Std, "%ld, %ld, %ld, %ld, ",
  242.              gad->g_Left - IE->ScreenData->XOffset,
  243.              gad->g_Top  - IE->ScreenData->YOffset,
  244.              gad->g_Width, gad->g_Height );
  245.  
  246.         if( gad->g_Titolo[0] ) {
  247.         if( loc )
  248.             FPrintf( Files->Std, "(UBYTE *)%s", (( *IE->Functions->FindString )( &IE->Locale->ExtraStrings, gad->g_Titolo ))->ID );
  249.         else
  250.             FPrintf( Files->Std, "\"%s\"", gad->g_Titolo );
  251.         } else
  252.         FPuts( Files->Std, Null );
  253.  
  254.         FPuts( Files->Std, ", " );
  255.  
  256.         if( gad->g_Font )
  257.         FPrintf( Files->Std, "&%s", gad->g_Font->txa_Label );
  258.         else
  259.         FPuts( Files->Std, Null );
  260.  
  261.         FPrintf( Files->Std, ", GD_%s, ", gad->g_Label );
  262.  
  263.         if( gad->g_Flags ) {
  264.  
  265.         buffer[0] = '\0';
  266.  
  267.         if( gad->g_Flags & 32 ) {
  268.             strcpy( buffer, "NG_HIGHLABEL" );
  269.             or = "|";
  270.         } else
  271.             or = "";
  272.  
  273.  
  274.         c = gad->g_Flags & 0xFFDF;
  275.         if( c ) {
  276.             strcat( buffer, or );
  277.  
  278.             c2 = 0;
  279.             while(!( c & gadget_flags[ c2 ]))
  280.             c2 += 1;
  281.  
  282.             strcat( buffer, GadFlags[ c2 ]);
  283.         }
  284.  
  285.         FPuts( Files->Std, buffer );
  286.         } else
  287.         FPuts( Files->Std, Null );
  288.  
  289.  
  290.         FPuts( Files->Std, ", NULL, " );
  291.  
  292.         if(( Prefs.Flags & CLICKED ) && ( gad->g_Kind != TEXT_KIND ) && ( gad->g_Kind != NUMBER_KIND ))
  293.         FPrintf( Files->Std, "(APTR)%sClicked", gad->g_Label );
  294.         else
  295.         FPuts( Files->Std, Null );
  296.  
  297.         FPuts( Files->Std, ",\n\t" );
  298.     }
  299.     }
  300.  
  301.     Flush( Files->Std );
  302.     Seek( Files->Std, -3, OFFSET_CURRENT );
  303.     FPuts( Files->Std, "\n};\n" );
  304. }
  305. ///
  306. /// WriteTags
  307. void WriteTags( struct GenFiles *Files, struct IE_Data *IE, struct MinList *Gadgets, ULONG loc )
  308. {
  309.     struct GadgetInfo  *gad;
  310.  
  311.     for( gad = Gadgets->mlh_Head; gad->g_Node.ln_Succ; gad = gad->g_Node.ln_Succ ) {
  312.     if( gad->g_Kind < BOOLEAN ) {
  313.  
  314.         if( gad->g_Tags & 1 )
  315.         FPuts( Files->Std, "(GT_Underscore), '_', " );
  316.  
  317.         switch( gad->g_Kind ) {
  318.  
  319.         case BUTTON_KIND:
  320.             if( gad->g_Tags & 2 )
  321.             FPuts( Files->Std, GADisabled );
  322.             if( gad->g_Tags & 4 )
  323.             FPuts( Files->Std, GAImmediate );
  324.             break;
  325.  
  326.         case CHECKBOX_KIND:
  327.             if( gad->g_Tags & 2 )
  328.             FPuts( Files->Std, GADisabled );
  329.             if( gad->g_Tags & 4 )
  330.             FPuts( Files->Std, "(GTCB_Checked), TRUE, " );
  331.             if( gad->g_Tags & 8 )
  332.             FPuts( Files->Std, "(GTCB_Scaled), TRUE, " );
  333.             break;
  334.  
  335.         case INTEGER_KIND:
  336.             if( ((struct IK)(gad->g_Data)).Num )
  337.             FPrintf( Files->Std, "(GTIN_Number), %ld, ", ((struct IK)(gad->g_Data)).Num );
  338.             if( ((struct IK)(gad->g_Data)).MaxC != 10 )
  339.             FPrintf( Files->Std, "(GTIN_MaxChars), %ld, ", ((struct IK)(gad->g_Data)).MaxC );
  340.             if( ((struct IK)(gad->g_Data)).Just )
  341.             FPrintf( Files->Std, "(STRINGA_Justification), %s, ", STRINGA_txts[ ((struct IK)(gad->g_Data)).Just ]);
  342.             if( gad->g_Tags & 2 )
  343.             FPuts( Files->Std, GADisabled );
  344.             if( gad->g_Tags & 4 )
  345.             FPuts( Files->Std, GAImmediate );
  346.             if(!( gad->g_Tags & 8 ))
  347.             FPuts( Files->Std, GATabCycle );
  348.             if( gad->g_Tags & 0x10 )
  349.             FPuts( Files->Std, STRINGAExitHelp );
  350.             if( gad->g_Tags & 0x20 )
  351.             FPuts( Files->Std, STRINGAReplaceMode );
  352.             break;
  353.  
  354.         case LISTVIEW_KIND:
  355.             if( gad->g_NumScelte )
  356.             FPrintf( Files->Std, "(GTLV_Labels), (ULONG)&%sList, ", gad->g_Label );
  357.             if( ((struct LK)(gad->g_Data)).Top )
  358.             FPrintf( Files->Std, "(GTLV_Top), %ld, ", ((struct LK)(gad->g_Data)).Top );
  359.             if( ((struct LK)(gad->g_Data)).Vis )
  360.             FPrintf( Files->Std, "(GTLV_MakeVisible), %ld, ", ((struct LK)(gad->g_Data)).Vis );
  361.             if( ((struct LK)(gad->g_Data)).ScW != 16 )
  362.             FPrintf( Files->Std, "(GTLV_ScrollWidth), %ld, ", ((struct LK)(gad->g_Data)).ScW );
  363.             if( ((struct LK)(gad->g_Data)).MultiSelect )
  364.             FPuts( Files->Std, "(GTLV_CallBack), (ULONG)&ListHook, " );
  365.             else if( ((struct LK)(gad->g_Data)).Sel )
  366.             FPrintf( Files->Std, "(GTLV_Selected), %ld, ", ((struct LK)(gad->g_Data)).Sel );
  367.             if( ((struct LK)(gad->g_Data)).Spc )
  368.             FPrintf( Files->Std, LAYOUTASpacing, ((struct LK)(gad->g_Data)).Spc );
  369.             if( ((struct LK)(gad->g_Data)).IH )
  370.             FPrintf( Files->Std, "(GTLV_ItemHeight), %ld, ", ((struct LK)(gad->g_Data)).IH );
  371.             if( ((struct LK)(gad->g_Data)).MaxP )
  372.             FPrintf( Files->Std, "(GTLV_MaxPen), %ld, ", ((struct LK)(gad->g_Data)).MaxP );
  373.             if( gad->g_Tags & 2 )
  374.             FPuts( Files->Std, GADisabled );
  375.             if( gad->g_Tags & 4 )
  376.             FPuts( Files->Std, "(GTLV_ReadOnly), TRUE, " );
  377.             if( gad->g_Tags & 8 )
  378.             FPuts( Files->Std, "(GTLV_ShowSelected), NULL, " );
  379.             break;
  380.  
  381.         case MX_KIND:
  382.             FPuts( Files->Std, "(GTMX_Labels), (ULONG)&" );
  383.             if( loc )
  384.             FPrintf( Files->Std, "%s", (( *IE->Functions->FindArray )( &IE->Locale->Arrays, &gad->g_Scelte ))->Label );
  385.             else
  386.             FPrintf( Files->Std, "%sLabels", gad->g_Label );
  387.             FPuts( Files->Std, "[0], " );
  388.             if( ((struct MK)(gad->g_Data)).Act )
  389.             FPrintf( Files->Std, "(GTMX_Active), %ld, ", ((struct MK)(gad->g_Data)).Act );
  390.             if( ((struct MK)(gad->g_Data)).Spc != 1 )
  391.             FPrintf( Files->Std, "(GTMX_Spacing), %ld, ", ((struct MK)(gad->g_Data)).Spc );
  392.             if( gad->g_Titolo[0] )
  393.             FPrintf( Files->Std, "(GTMX_TitlePlace), %s, ", GadFlags[ ((struct MK)(gad->g_Data)).TitPlc ]);
  394.             if( gad->g_Tags & 2 )
  395.             FPuts( Files->Std, GADisabled );
  396.             if( gad->g_Tags & 4 )
  397.             FPuts( Files->Std, "(GTMX_Scaled), TRUE, " );
  398.             break;
  399.  
  400.         case NUMBER_KIND:
  401.             if( ((struct NK)(gad->g_Data)).Num )
  402.             FPrintf( Files->Std, "(GTNM_Number), %ld, ", ((struct NK)(gad->g_Data)).Num );
  403.             if( ((struct NK)(gad->g_Data)).FPen != -1 )
  404.             FPrintf( Files->Std, "(GTNM_FrontPen), %ld, ", ((struct NK)(gad->g_Data)).FPen );
  405.             if( ((struct NK)(gad->g_Data)).BPen != -1 )
  406.             FPrintf( Files->Std, "(GTNM_BackPen), %ld, ", ((struct NK)(gad->g_Data)).BPen );
  407.             if( ((struct NK)(gad->g_Data)).Just )
  408.             FPrintf( Files->Std, "(GTNM_Justification), %s, ", GTJ_txts[ ((struct NK)(gad->g_Data)).Just ]);
  409.             if( ((struct NK)(gad->g_Data)).MNL != 10 )
  410.             FPrintf( Files->Std, "(GTNM_MaxNumberLen), %ld, ", ((struct NK)(gad->g_Data)).MNL );
  411.             if( strcmp( ((struct NK)(gad->g_Data)).Format, "%ld" )) {
  412.             FPuts( Files->Std, "(GTNM_Format), (ULONG)" );
  413.             if( loc )
  414.                 FPrintf( Files->Std, "%s, ", (( *IE->Functions->FindString )( &IE->Locale->ExtraStrings, ((struct NK)(gad->g_Data)).Format ))->ID );
  415.             else
  416.                 FPrintf( Files->Std, "\"%s\", ", ((struct NK)(gad->g_Data)).Format );
  417.             }
  418.             if( gad->g_Tags & 2 )
  419.             FPuts( Files->Std, "(GTNM_Border), TRUE, " );
  420.             if( gad->g_Tags & 4 )
  421.             FPuts( Files->Std, "(GTNM_Clipped), TRUE, " );
  422.             break;
  423.  
  424.         case CYCLE_KIND:
  425.             FPuts( Files->Std, "(GTCY_Labels), (ULONG)&" );
  426.             if( loc )
  427.             FPrintf( Files->Std, "%s", (( *IE->Functions->FindArray )( &IE->Locale->Arrays, &gad->g_Scelte ))->Label );
  428.             else
  429.             FPrintf( Files->Std, "%sLabels", gad->g_Label );
  430.             FPuts( Files->Std, "[0], " );
  431.             if( ((struct CK)(gad->g_Data)).Act )
  432.             FPrintf( Files->Std, "(GTCY_Active), %ld, ", ((struct CK)(gad->g_Data)).Act );
  433.             if( gad->g_Tags & 2 )
  434.             FPuts( Files->Std, GADisabled );
  435.             break;
  436.  
  437.         case PALETTE_KIND:
  438.             if( ((struct PK)(gad->g_Data)).Depth != 1 )
  439.             FPrintf( Files->Std, "(GTPA_Depth), %ld, ", ((struct PK)(gad->g_Data)).Depth );
  440.             if( ((struct PK)(gad->g_Data)).Color != 1 )
  441.             FPrintf( Files->Std, "(GTPA_Color), %ld, ", ((struct PK)(gad->g_Data)).Color );
  442.             if( ((struct PK)(gad->g_Data)).ColOff )
  443.             FPrintf( Files->Std, "(GTPA_ColorOffset), %ld, ", ((struct PK)(gad->g_Data)).ColOff );
  444.             if( ((struct PK)(gad->g_Data)).IW )
  445.             FPrintf( Files->Std, "(GTPA_IndicatorWidth), %ld, ", ((struct PK)(gad->g_Data)).IW );
  446.             if( ((struct PK)(gad->g_Data)).IH )
  447.             FPrintf( Files->Std, "(GTPA_IndicatorHeight), %ld, ", ((struct PK)(gad->g_Data)).IH );
  448.             if(( ((struct PK)(gad->g_Data)).NumCol ) && ( ((struct PK)(gad->g_Data)).NumCol != 2 ))
  449.             FPrintf( Files->Std, "(GTPA_NumColors), %ld, ", ((struct PK)(gad->g_Data)).NumCol );
  450.             if( gad->g_Tags & 2 )
  451.             FPuts( Files->Std, GADisabled );
  452.             break;
  453.  
  454.         case SCROLLER_KIND:
  455.             if( ((struct SK)(gad->g_Data)).Top )
  456.             FPrintf( Files->Std, "(GTSC_Top), %ld, ", ((struct SK)(gad->g_Data)).Top );
  457.             if( ((struct SK)(gad->g_Data)).Tot )
  458.             FPrintf( Files->Std, "(GTSC_Total), %ld, ", ((struct SK)(gad->g_Data)).Tot );
  459.             if( ((struct SK)(gad->g_Data)).Vis != 2 )
  460.             FPrintf( Files->Std, "(GTSC_Visible), %ld, ", ((struct SK)(gad->g_Data)).Vis );
  461.             if( ((struct SK)(gad->g_Data)).Arr )
  462.             FPrintf( Files->Std, "(GTSC_Arrows), %ld, ", ((struct SK)(gad->g_Data)).Arr );
  463.             if( ((struct SK)(gad->g_Data)).Free )
  464.             FPuts( Files->Std, PGAFreedom );
  465.             if( gad->g_Tags & 2 )
  466.             FPuts( Files->Std, GADisabled );
  467.             if( gad->g_Tags & 2 )
  468.             FPuts( Files->Std, GARelVerify );
  469.             if( gad->g_Tags & 8 )
  470.             FPuts( Files->Std, GAImmediate );
  471.             break;
  472.  
  473.         case SLIDER_KIND:
  474.             if( ((struct SlK)(gad->g_Data)).Min )
  475.             FPrintf( Files->Std, "(GTSL_Min), %ld, ", ((struct SlK)(gad->g_Data)).Min );
  476.             if( ((struct SlK)(gad->g_Data)).Max != 15 )
  477.             FPrintf( Files->Std, "(GTSL_Max), %ld, ", ((struct SlK)(gad->g_Data)).Max );
  478.             if( ((struct SlK)(gad->g_Data)).Level )
  479.             FPrintf( Files->Std, "(GTSL_Level), %ld, ", ((struct SlK)(gad->g_Data)).Level );
  480.             if( ((struct SlK)(gad->g_Data)).MLL != 2 )
  481.             FPrintf( Files->Std, "(GTSL_MaxLevelLen), %ld, ", ((struct SlK)(gad->g_Data)).MLL );
  482.             FPrintf( Files->Std, "(GTSL_LevelPlace), %s, ", GadFlags[ ((struct SlK)(gad->g_Data)).LevPlc ]);
  483.             if( ((struct SlK)(gad->g_Data)).Just )
  484.             FPrintf( Files->Std, "(GTSL_Justification), %ld, ", GTJ_txts[ ((struct SlK)(gad->g_Data)).Just ]);
  485.             if( ((struct SlK)(gad->g_Data)).Free )
  486.             FPuts( Files->Std, PGAFreedom );
  487.             if( ((struct SlK)(gad->g_Data)).MPL )
  488.             FPrintf( Files->Std, "(GTSL_MaxPixelLen), %ld, ", ((struct SlK)(gad->g_Data)).MPL );
  489.             FPuts( Files->Std, "(GTSL_LevelFormat), (ULONG)" );
  490.             if( loc )
  491.             FPrintf( Files->Std, "%s, ", (( *IE->Functions->FindString )( &IE->Locale->ExtraStrings, ((struct SlK)(gad->g_Data)).Format ))->ID );
  492.             else
  493.             FPrintf( Files->Std, "\"%s\", ", ((struct SlK)(gad->g_Data)).Format );
  494.             if( gad->g_Tags & 2 )
  495.             FPuts( Files->Std, GADisabled );
  496.             if( gad->g_Tags & 2 )
  497.             FPuts( Files->Std, GARelVerify );
  498.             if( gad->g_Tags & 8 )
  499.             FPuts( Files->Std, GAImmediate );
  500.             break;
  501.  
  502.         case STRING_KIND:
  503.             if( ((struct StK)(gad->g_Data)).MaxC )
  504.             FPrintf( Files->Std, "(GTST_MaxChars), %ld, ", ((struct StK)(gad->g_Data)).MaxC );
  505.             if( ((struct StK)(gad->g_Data)).Just )
  506.             FPrintf( Files->Std, "(STRINGA_Justification), %s, ", STRINGA_txts[ ((struct StK)(gad->g_Data)).Just ]);
  507.             if ( *((UBYTE *)(gad->g_ExtraMem)) ) {
  508.             FPuts( Files->Std, "(GTST_String), (ULONG)" );
  509.             if( loc )
  510.                 FPrintf( Files->Std, "%s, ", (( *IE->Functions->FindString )( &IE->Locale->ExtraStrings, gad->g_ExtraMem ))->ID );
  511.             else
  512.                 FPrintf( Files->Std, "\"%s\", ", gad->g_ExtraMem );
  513.             }
  514.             if( gad->g_Tags & 2 )
  515.             FPuts( Files->Std, GADisabled );
  516.             if( gad->g_Tags & 4 )
  517.             FPuts( Files->Std, GAImmediate );
  518.             if(!( gad->g_Tags & 8 ))
  519.             FPuts( Files->Std, GATabCycle );
  520.             if( gad->g_Tags & 0x10 )
  521.             FPuts( Files->Std, STRINGAExitHelp );
  522.             if( gad->g_Tags & 0x20 )
  523.             FPuts( Files->Std, STRINGAReplaceMode );
  524.             break;
  525.  
  526.         case TEXT_KIND:
  527.             if( ((struct TK)(gad->g_Data)).FPen != -1 )
  528.             FPrintf( Files->Std, "(GTTX_FrontPen), %ld, ", ((struct TK)(gad->g_Data)).FPen );
  529.             if( ((struct TK)(gad->g_Data)).BPen != -1 )
  530.             FPrintf( Files->Std, "(GTTX_BackPen), %ld, ", ((struct TK)(gad->g_Data)).BPen );
  531.             if( ((struct TK)(gad->g_Data)).Just )
  532.             FPrintf( Files->Std, "(GTTX_Justification), %s, ", GTJ_txts[ ((struct TK)(gad->g_Data)).Just ]);
  533.             if ( *((UBYTE *)(gad->g_ExtraMem)) ) {
  534.             FPuts( Files->Std, "(GTTX_Text), (ULONG)" );
  535.             if( loc )
  536.                 FPrintf( Files->Std, "%s, ", (( *IE->Functions->FindString )( &IE->Locale->ExtraStrings, gad->g_ExtraMem ))->ID );
  537.             else
  538.                 FPrintf( Files->Std, "\"%s\", ", gad->g_ExtraMem );
  539.             }
  540.             if( gad->g_Tags & 2 )
  541.             FPuts( Files->Std, "(GTTX_CopyText), TRUE, " );
  542.             if( gad->g_Tags & 4 )
  543.             FPuts( Files->Std, "(GTTX_Border), TRUE, " );
  544.             if( gad->g_Tags & 8 )
  545.             FPuts( Files->Std, "(GTTX_Clipped), TRUE, " );
  546.             break;
  547.         }
  548.  
  549.         FPuts( Files->Std, "(TAG_DONE),\n\t" );
  550.     }
  551.     }
  552.  
  553.     Flush( Files->Std );
  554.     Seek( Files->Std, -3, OFFSET_CURRENT );
  555.     FPuts( Files->Std, "\n};\n" );
  556. }
  557. ///
  558. /// WriteBooleans
  559. void WriteBooleans( struct GenFiles *Files, struct IE_Data *IE, struct MinList *Gadgets, struct WindowInfo *wnd )
  560. {
  561.     struct BooleanInfo *gad, *next;
  562.     UBYTE              *str;
  563.     struct ImageNode   *img;
  564.     LONG                loc;
  565.  
  566.     loc = Prefs.Flags & SMART_STR;
  567.  
  568.     if( IE->SrcFlags & LOCALIZE )
  569.     loc = wnd->wi_Tags & W_LOC_GADGETS;
  570.  
  571.     for( gad = Gadgets->mlh_TailPred; gad->b_Node.ln_Pred; gad = gad->b_Node.ln_Pred ) {
  572.     if( gad->b_Kind == BOOLEAN ) {
  573.  
  574.         if(( gad->b_flags2 & B_TEXT ) && ( gad->b_Titolo[0] )) {
  575.  
  576.         FPrintf( Files->Std, "\nstruct IntuiText %sIText = {\n", gad->b_Label );
  577.  
  578.         FPrintf( Files->Std, "\t%ld, %ld, %ld,\n"
  579.                       "\t%ld, %ld,\n\t",
  580.               gad->b_FrontPen, gad->b_BackPen,
  581.               gad->b_DrawMode, gad->b_TxtLeft,
  582.               gad->b_TxtTop );
  583.  
  584.         if( gad->b_Font )
  585.             FPrintf( Files->Std, "&%s", gad->b_Font->txa_Label );
  586.         else
  587.             FPuts( Files->Std, Null );
  588.  
  589.         FPuts( Files->Std, ",\n\t(UBYTE *)" );
  590.  
  591.         if( loc )
  592.             FPrintf( Files->Std, "%s", (( *IE->Functions->FindString )( &IE->Locale->ExtraStrings, gad->b_Titolo ))->ID );
  593.         else
  594.             FPrintf( Files->Std, "\"%s\"", gad->b_Titolo );
  595.         FPuts( Files->Std, ",\n\tNULL\n};\n" );
  596.         }
  597.  
  598.         str = ( wnd->wi_IDCMP & IDCMP_GADGETHELP ) ? "extern struct ExtGadget\t\t%sGadget;\n" : "extern struct Gadget\t\t%sGadget;\n";
  599.         FPrintf( Files->XDef, str, gad->b_Label );
  600.  
  601.         str = ( wnd->wi_IDCMP & IDCMP_GADGETHELP ) ? "\nstruct ExtGadget %sGadget = {\n\t" : "\nstruct Gadget %sGadget = {\n\t";
  602.         FPrintf( Files->Std, str, gad->b_Label );
  603.  
  604.         next = gad->b_Node.ln_Succ;
  605.         if( next->b_Node.ln_Succ )
  606.         FPrintf( Files->Std, "&%sGadget", next->b_Label );
  607.         else
  608.         FPuts( Files->Std, Null );
  609.  
  610.  
  611.         FPrintf( Files->Std, ",\n\t%ld, %ld, %ld, %ld,\n",
  612.              gad->b_Left - IE->ScreenData->XOffset,
  613.              gad->b_Top  - IE->ScreenData->YOffset,
  614.              gad->b_Width, gad->b_Height );
  615.  
  616.  
  617.         VFPrintf( Files->Std, "\t0x%04x, 0x%04x, 1,\n", &gad->b_Flags );
  618.  
  619.  
  620.         if( img = gad->b_GadgetRender ) {
  621.         (ULONG)img -= sizeof( struct Node );
  622.         FPrintf( Files->Std, "\t&%sImg, ", img->in_Label );
  623.         } else
  624.         FPuts( Files->Std, "\tNULL, " );
  625.  
  626.  
  627.         if( img = gad->b_SelectRender ) {
  628.         (ULONG)img -= sizeof( struct Node );
  629.         FPrintf( Files->Std, "&%sImg,\n", img->in_Label );
  630.         } else
  631.         FPuts( Files->Std, "NULL,\n" );
  632.  
  633.  
  634.         if(( gad->b_flags2 & B_TEXT ) && ( gad->b_Titolo[0] ))
  635.         FPrintf( Files->Std, "\t&%sIText", gad->b_Label );
  636.         else
  637.         FPuts( Files->Std, "\tNULL" );
  638.  
  639.         FPrintf( Files->Std, ",\n\t0, 0,\n\tGD_%s,\n\t", gad->b_Label );
  640.  
  641.         if( Prefs.Flags & CLICKED )
  642.         FPrintf( Files->Std, "(APTR)%sClicked", gad->b_Label );
  643.         else
  644.         FPuts( Files->Std, Null );
  645.  
  646.         if( wnd->wi_IDCMP & IDCMP_GADGETHELP )
  647.         FPrintf( Files->Std, ",\n\t3,\n\t%ld, %ld, %ld, %ld",
  648.              gad->b_Left - IE->ScreenData->XOffset,
  649.              gad->b_Top  - IE->ScreenData->YOffset,
  650.              gad->b_Width, gad->b_Height );
  651.  
  652.         FPuts( Files->Std, "\n};\n" );
  653.     }
  654.     }
  655. }
  656. ///
  657. /// WriteGTypes
  658. void WriteGTypes( struct GenFiles *Files, struct IE_Data *IE, struct MinList *Gadgets )
  659. {
  660.     struct GadgetInfo  *gad;
  661.  
  662.     for( gad = Gadgets->mlh_Head; gad->g_Node.ln_Succ; gad = gad->g_Node.ln_Succ ) {
  663.     if( gad->g_Kind < BOOLEAN ) {
  664.         FPuts( Files->Std, GadKinds[ gad->g_Kind - 1 ]);
  665.         FPuts( Files->Std, ",\n\t" );
  666.     }
  667.     }
  668.  
  669.     FPuts( Files->Std, "NULL };\n" );
  670. }
  671. ///
  672. /// WriteGLabels
  673. void WriteGLabels( struct GenFiles *Files, struct IE_Data *IE, struct MinList *Gadgets, struct WindowInfo *Wnd )
  674. {
  675.     struct GadgetInfo  *gad;
  676.     ULONG               loc;
  677.  
  678.     loc = Prefs.Flags & SMART_STR;
  679.  
  680.     if( IE->SrcFlags & LOCALIZE )
  681.     loc = Wnd->wi_Tags & W_LOC_GADGETS;
  682.  
  683.     for( gad = Gadgets->mlh_Head; gad->g_Node.ln_Succ; gad = gad->g_Node.ln_Succ ) {
  684.  
  685.     switch( gad->g_Kind ) {
  686.  
  687.         case LISTVIEW_KIND:
  688.         WriteList( Files, &gad->g_Scelte, gad->g_Label, gad->g_NumScelte, IE );
  689.         break;
  690.  
  691.         case MX_KIND:
  692.         case CYCLE_KIND:
  693.  
  694.         if(!( loc )) {
  695.             struct GadgetScelta *gs;
  696.  
  697.             FPrintf( Files->XDef, "extern UBYTE\t\t\t*%sLabels[];\n", gad->g_Label );
  698.             FPrintf( Files->Std,  "\nUBYTE *%sLabels[] = {\n\t", gad->g_Label );
  699.  
  700.             for( gs = gad->g_Scelte.mlh_Head; gs->gs_Node.ln_Succ; gs = gs->gs_Node.ln_Succ )
  701.             FPrintf( Files->Std, "(UBYTE *)\"%s\",\n\t", gs->gs_Testo );
  702.  
  703.             FPuts( Files->Std, "NULL\n};\n" );
  704.         }
  705.         break;
  706.     }
  707.     }
  708. }
  709. ///
  710.  
  711.